package  
{
	import net.flashpunk.World;
	
	public class fracasWorld extends World
	{
		//Entites
		public static var fraci:Vector.<Fracas> = new Vector.<Fracas>;// (MAX_FRACI);
		public static var girder:Girder;
		public static var rupee:Rupee;
		public var background:Background;
		//Text Entities
		public static var wallbounce:Vector.<WallBounce> = new Vector.<WallBounce>;
		public static var streaktext:streakText;
		public static var girdertext:girderPointsText;		
		public var scoretext:scoreText;
		//ints
		public const MAX_FRACI:int = 50;
		public var fracas_add:int = 100;	//time til the next fracas
		public var fracas_count: int = 0;	//which fracas in the array
		public static var fraci_in_play: int = 1;	//number of fraci currently bouncing around
		public static var score:int;
		public static var streak:int;
		
		public function fracasWorld() 
		{
			scoretext = new scoreText();
			add(scoretext);
			score = 0;
			fracasWorld.streaktext = new streakText;
			add(streaktext);
			streak = 0;
			fracasWorld.girdertext = new girderPointsText;
			add(girdertext);
			for (var i:int = 0; i < MAX_FRACI; i++) {
				fracasWorld.fraci[i] = new Fracas();
				fracasWorld.wallbounce[i] = new WallBounce();
			}
			add(fraci[0]);
			add(wallbounce[0]);
			fracasWorld.girder = new Girder;
			add(girder);
			fracasWorld.rupee = new Rupee;
			add(rupee);
			background = new Background();
			add(background);
			
		}
		
		override public function update():void {
			fracas_add--;
			if (fraci_in_play == 0) fracas_add = 0;
			if (fracas_add == 0 && fracas_count < MAX_FRACI - 1 ) {
				fraci_in_play++;
				fracas_add = (Math.random() * 200) + 100;
				fracas_count++;
				add(fraci[fracas_count]);
				add(wallbounce[fracas_count]);
			}
			
			super.update();
		}
		
	}

}